package com.anc.platform.config;

import lombok.Data;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.cloud.context.config.annotation.RefreshScope;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
@Data
@RefreshScope
public class SendMailConfiguration {

    @Value("${send.mail.host:smtp.exmail.qq.com}")
    private String host;
    @Value("${send.mail.port:465}")
    private Integer port;
    @Value("${send.mail.auth:true}")
    private boolean auth;
    @Value("${send.mail.from:}")
    private String from;
    @Value("${send.mail.user:}")
    private String user;
    @Value("${send.mail.pass:}")
    private String pass;
    @Value("${send.mail.sslEnable:true}")
    private boolean sslEnable;

    @Bean
    @RefreshScope
    public MailAccount mailAccount() {
        MailAccount account = new MailAccount();
        account.setHost(from);

        return account;
    }
    @Data
    public class MailAccount{
        private String host;
    }
}
